//
//  NSDate+MMGTimestamp.m
//  MyApp
//
//  Created by Don on 2017/8/28.
//  Copyright © 2017年 com.memego. All rights reserved.
//

#import "NSDate+MMGTimestamp.h"

static NSString *const DEFAULT_TIME_ZONE              = @"Asia/Beijing";
static NSString *const DATE_MSEC_FORMAT               = @"yyyyMMddHHmmssSSS";

@implementation NSDate (MMGTimestamp)
+ (long long)mmg_currentTimeStamp {
    
    //北京时区当前时间
    NSDate *date = [NSDate date];
    NSDateFormatter *dateFomater = [[NSDateFormatter alloc]init];
    dateFomater.timeZone = [NSTimeZone timeZoneWithName:DEFAULT_TIME_ZONE];
    dateFomater.dateFormat = DATE_MSEC_FORMAT;
    NSString *original = [dateFomater stringFromDate:date];
    NSDate *cDate = [dateFomater dateFromString:original];
    
    long long ts = [[self class] mmg_timeStampWithDate:cDate];
    
    return ts;
}

+ (long long)mmg_timeStampWithDate:(NSDate *)date {
    long long ts = [date timeIntervalSince1970] * 1000;
    return ts;
}
@end
